<!-- Copyright (c) 2002 by ObjectLearn. All Rights Reserved. -->
<%@page import="com.zucc.core.po.Equipment"%>
<%@page import="com.zucc.core.po.Reservation"%>
<%@page import="com.mysql.fabric.xmlrpc.base.Data"%>
<%@page import="org.springframework.ui.Model"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>   
    <%@	page import="java.util.List" %>
    <%@	page import="com.zucc.core.po.MeetingRoom" %> 
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="zucc" uri="http://zucc.com/common/"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() 
	                   + ":" + request.getServerPort() + path + "/";
%>
<html>
	<head>
		<title>Welcome</title>
		<!-- 引入css样式文件 -->
	<!-- Bootstrap Core CSS -->
	<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />
	<!-- MetisMenu CSS -->
	<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet" />
	<!-- DataTables CSS -->
	<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet" />
	<!-- Custom CSS -->
	<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet" />
	<!-- Custom Fonts -->
	<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet" type="text/css" />
		
	</head>
	<body>
		<div id="wrapper">
		<!-- 导航栏部分 -->
		  <nav class="navbar navbar-default navbar-static-top" role="navigation"
				 style="margin-bottom: 0">
			<div class="navbar-header">
				<a class="navbar-brand" href="<%=basePath%>customer/list.action">WHT会议管理系统 v2.0</a>
			</div>
			<li class="dropdown">
				<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 
					<i class="fa fa-user fa-fw"></i>
					<i class="fa fa-caret-down"></i>
				</a>
				<ul class="dropdown-menu dropdown-user">
					<li><a href="#"><i class="fa fa-gear fa-fw"></i>
					用户:${user_session.userName }</a></li>
					<li>
					<a href="${pageContext.request.contextPath }/logout.action">
					<i class="fa fa-sign-out fa-fw"></i>退出登录
					</a>
					</li>
				</ul>
		</li>
		<div id="page-wrapper" >
		
			<a href="#" class="btn btn-primary" data-toggle="modal" 
		           data-target="#newMRDialog" onclick="clearMR()">添加会议室</a>
		           
		      <a href="${pageContext.request.contextPath }/mr/sr/viewRes.action" class="btn btn-primary">查看会议室预定情况</a>
		      <a href="${pageContext.request.contextPath }/mr/viewUse.action" class="btn btn-primary">查看会议室使用情况</a>
			<div class="panel panel-default">
					<div class="panel-heading">会议室信息列表</div>
					<!-- /.panel-heading -->
					<table class="table table-bordered table-striped">
						<thead>
							<tr>
								<th>编号</th>
								<th>会议室名称</th>
								<th>会议室状态</th>
								<th>会议室大小</th>
								
							</tr>
						</thead>
						<tbody>
						<%
							int i=0;
						%>
							<c:forEach items="${page}" var="row">
								<tr>
									<td>${row.m_R_id}</td>
									<td>${row.m_Name}</td>
									<td>${row.m_State}</td>
									<td>可容纳${row.m_Size}人</td>
									
									<td>
										
										<a href="#" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#mrEditDialog" onclick= "editMR(${row.m_R_id})">设置会议室</a>
										<a href="#" class="btn btn-danger btn-xs" onclick="deleteMR(${row.m_R_id})">删除</a>
										<!--
										<%										
										List<MeetingRoom> row=(List<MeetingRoom>)request.getAttribute("page");
										String check=row.get(i).getM_State();
										if(check.equals("正在开会")){
											out.print("<a href='#' class='btn btn-primary  btn-xs' onclick='viewMeeting("+row.get(i).getM_R_id() +")'>"+"查看会议"+"</a>");
										}										
											i++;
										%>
										
										  -->
										
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					
					<!-- /.panel-body -->
				</div>
				</div>
				</div>
				<!-- 创建MR模态框 -->
<div class="modal fade" id="newMRDialog" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">新建会议室信息</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" id="new_mr_form">
					<div class="form-group">
						<label for="new_mrName" class="col-sm-2 control-label">
						    会议室名称
						</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_mrName" placeholder="会议室名称" name="m_Name" />
						</div>
					</div>
					<div class="form-group">
						<label for="new_size" class="col-sm-2 control-label">会议室大小</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="new_size" placeholder="大小" name="m_Size" />
						</div>
						
					</div>
					<div class="form-group">
							<label for="new_size" class="col-sm-2 control-label">选择设备</label>
								<c:forEach items="${equs}" var="row">
									<tr>
									    <td >
									        <input type="checkbox" name="equ" value="${row.equId}">${row.equName}
									       
									    </td>
									</tr>

								</c:forEach>
						</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" onclick="createMR()">创建会议室</button>
			</div>
		</div>
	</div>
</div>
<!-- 设置会议室模态框 -->
<div class="modal fade" id="mrEditDialog" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">设置会议室</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" id="edit_mr_form">
					<input type="hidden" id="edit_mr_id" name="m_R_id"/>
					<div class="form-group">
						<label for="res_mrName" class="col-sm-2 control-label">会议室名称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="edit_mrName" placeholder="会议室名称" name="m_Name" />
						</div>
					</div>
					<div class="form-group">
						<label for="res_Size" class="col-sm-2 control-label">会议室大小</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="edit_Size" placeholder="会议室大小" name="m_Size" />
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" onclick="updateMR()">保存修改</button>
			</div>
		</div>
	</div>
</div>


<!-- 引入js文件 -->
<!-- jQuery -->
<script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="<%=basePath%>js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="<%=basePath%>js/sb-admin-2.js"></script>
<!-- 编写js代码 -->
<script type="text/javascript">
//清空新建会议室窗口中的数据
	function clearMR() {
	    $("#new_mrName").val("");
	    $("#new_size").val("")
	}
	// 创建会议室
	function createMR() {
	$.post("<%=basePath%>/mr/create.action",
	$("#new_mr_form").serialize(),function(data){
	        if(data =="OK"){
	            alert("会议室创建成功！");
	            window.location.reload();
	        }else{
	            alert("会议室创建失败！");
	            window.location.reload();
	        }
	    });
	}
	// 通过id获取设置的会议室信息
	function editMR(id) {
	    $.ajax({
	        type:"get",
	        url: "<%=basePath%>mr/getMRById.action",
	        data:{"id":id},
	        success:function(data) {
	            $("#edit_mr_id").val(data.m_R_id);
	            $("#edit_mrName").val(data.m_Name);
	            $("#edit_Size").val(data.m_Size);
	            
	            
	        }
	    });
	}
    // 执行修改会议室设置操作
	function updateMR() {
		$.post("<%=basePath%>mr/updateMR.action",$("#edit_mr_form").serialize(),function(data){
			if(data =="OK"){
				alert("会议室信息更新成功！");
				window.location.reload();
			}else{
				alert("会议室信息更新失败！");
				window.location.reload();
			}
		});
		
		
	}
	// 删除客户
	function deleteMR(id) {
	    if(confirm('确实要删除该会议室吗?')) {
	$.post("<%=basePath%>mr/delete.action",{"id":id},
	function(data){
	            if(data =="OK"){
	                alert("删除会议室成功！");
	                window.location.reload();
	            }else{
	                alert("删除会议室失败！");
	                window.location.reload();
	            }
	        });
	    }
	}
	
</script>
	</body>
</html>
